﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LL.Business;
using NanoERP.Model;

namespace NanoERP.Business.BaseInfo
{
    /// <summary>
    /// 部门信息业务类
    /// </summary>
    public class DeptinfoBLL : ServiceBase
    {
        /// <summary>
        /// 部门信息查询
        /// </summary>
        /// <param name="depatId">部门ID</param>
        /// <returns></returns>
        public List<Deptinfo> Query(int depatId)
        {
            var session = this.DbSession;

            return session.Query<Deptinfo>("PARENTDEPTID=@0", depatId).ToList();
        }

        /// <summary>
        /// 部门信息
        /// </summary>
        /// <param name="id">部门信息ID</param>
        /// <returns></returns>
        public Deptinfo Get(long id)
        {
            return this.DbSession.Get<Deptinfo>(id);
        }

        /// <summary>
        /// 编辑部门信息
        /// </summary>
        /// <param name="o"></param>
        public void Edit(Deptinfo o)
        {
            var session = this.DbSession;
            if (o.Id == 0) session.Insert(o, "Id");
            else
                session.Update(o);
        }

        /// <summary>
        /// 删除部门信息
        /// </summary>
        /// <param name="id"></param>
        public void Delete(int id)
        {
            var session = this.DbSession;
            session.Delete<Deptinfo>(id);
        }
    }
}
